package com.boot.multi.source.service.impl;

import com.boot.multi.source.domain.producer.ProducerUser;
import com.boot.multi.source.mapper.producer.ProducerUserMapper;
import com.boot.multi.source.service.ProducerUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 刘志强
 * @date 2020/11/27 14:22
 */
@Service
public class ProducerUserImpl implements ProducerUserService {

    @Autowired
    private ProducerUserMapper producerUserMapper;

    @Override
    public ProducerUser getProducerUser(Long id) {
        return producerUserMapper.getProducerUserById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class,transactionManager="producerTransactionManager")
    public String addProducerUser(ProducerUser producerUser) {
        int i = producerUserMapper.addProducerUser(producerUser);
        if ( i > 0 ) {
            return "添加成功";
        } else {
            return "添加失败";
        }
    }
}
